<?php defined('APP_PATH') or exit('Access Denied');?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>配置菜单</title>
<link rel="stylesheet" type="text/css" href="vonuo/static/css/vonuo.css">
<script type="text/javascript" src="vonuo/static/js/jquery.min.js"></script>
<script type="text/javascript" src="vonuo/static/js/tablecolor.js"></script>
<script type="text/javascript">
function selChildMenu(id, type){
	$(".menu_"+id).attr("checked", type);
}
function selParentMenu(id, type){
	if(type){
		$("#menu_"+id).attr("checked", true);
	}
}
function check(){
	var i = 0;
	var j = 0;
	$("input[name='group_id[]']").each(function(){
		if($(this).attr('checked')){
			i++;
		}
	});
	$("input[name='menu[]']").each(function(){
		if($(this).attr('checked')){
			j++;
		}
	});
	if(i == 0){
		alert('请选择管理组');
		return false;
	}
	if(j == 0){
		alert('请选择菜单');
		return false;
	}
	$("form").submit();
}
</script>
</head>

<body>
<div class="gs_wraper gs_p_l0">
	<div class="title">
		<a href="javascript:;" class="hover">配置菜单</a>
		<a href="<?php echo spUrl('aacl','conf',array('id'=>$group['id']));?>">配置权限</a>
	</div>
	<form action="<?php echo spUrl('menu','doconf');?>" method="post">
	<div class="qxfp clearfix">
		<h2>选择管理组</h2>
		<ul class="fie_ul clearfix">
		<?php foreach($groups as $v){?>
			<li><input name="group_id[]" type="checkbox" value="<?php echo $v['id'];?>" <?php if($v['id'] == $group['id']){?>checked<?php }?> /><label><?php echo $v['name'];?></label></li>
		<?php }?>
		</ul>
	</div>
	<?php foreach($menus as $v){?>
	<div class="qxfp clearfix">
		<h2><input name="menu[]" id="menu_<?php echo $v['id'];?>" type="checkbox" value="<?php echo $v['id'];?>" onclick="selChildMenu(<?php echo $v['id'];?>, $(this).attr('checked'));" <?php if(in_array($v['id'], $myMenus)){?>checked<?php }?> /><label><?php echo $v['name'];?></label></h2>
		<ul class="fie_ul clearfix">
		<?php foreach($v['child'] as $v2){?>
			<li><input name="menu[]" type="checkbox" class="menu_<?php echo $v['id'];?>" value="<?php echo $v2['id'];?>" onclick="selParentMenu(<?php echo $v['id'];?>, $(this).attr('checked'));" <?php if(in_array($v2['id'], $myMenus)){?>checked<?php }?> /><label><?php echo $v2['name'];?></label></li>
		<?php }?>
		</ul>
	</div>
	<?php }?>
	</form>
	<a href="javascript:;" class="sure_submit" onclick="check();" style="margin-left:10px">确定</a>
</div>
</body>
</html>